﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TreeList
{
    public partial class BulkTreeControl : UserControl
    {
        public BulkTreeControl()
        {
            InitializeComponent();
            Bytargeting.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
        }
        public event Action<string> IndexChanged;

        private void select_item_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;
            if (IndexChanged != null)
            {
                IndexChanged(btn.Name);
            }
            SetNodeBackColor(btn.Name);
        }

        private void SetNodeBackColor(string nodeName)
        {
            switch (nodeName)
            {
                case "createCampaign":
                    createCampaign.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
                    selectedAds.BackColor = 
                    Bytargeting.BackColor = 
                    Bytitle.BackColor = 
                    Bybody.BackColor = 
                    Byimage.BackColor = this.BackColor;
                    break;
                case "selectedAds":
                    createCampaign.BackColor =
                    Bytargeting.BackColor =
                    Bytitle.BackColor =
                    Bybody.BackColor =
                    Byimage.BackColor = this.BackColor;
                    selectedAds.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);

                    break;
                case "Bytargeting":
                    Bytitle.BackColor =
                    Bybody.BackColor = 
                    Byimage.BackColor = 
                    createCampaign.BackColor = 
                    selectedAds.BackColor = this.BackColor;
                    Bytargeting.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
                    
                    break;
                case "Bytitle":
                    Bytitle.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
                    Bybody.BackColor = 
                    createCampaign.BackColor = 
                    selectedAds.BackColor = 
                    Bytargeting.BackColor = 
                    Byimage.BackColor = this.BackColor;
                    break;
                case "Bybody":
                    createCampaign.BackColor = 
                    selectedAds.BackColor = 
                    Bytargeting.BackColor =
                    Bytitle.BackColor =
                    Byimage.BackColor = this.BackColor;
                    Bybody.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
                    break;
                case "Byimage":
                    createCampaign.BackColor = 
                    selectedAds.BackColor = 
                    Bytargeting.BackColor = 
                    Bytitle.BackColor = 
                    Bybody.BackColor = this.BackColor;
                    Byimage.BackColor = System.Drawing.Color.FromArgb(164, 198, 231);
                    break;
            }
        }

        public bool ByTargetingEnable
        {
            get { return this.Bytargeting.Enabled; }
            set { this.Bytargeting.Enabled = value; }
        }

        public bool ByTitleEnable
        {
            get { return this.Bytitle.Enabled; }
            set { this.Bytitle.Enabled = value; }
        }

        public bool ByBodyEnable
        {
            get { return this.Bybody.Enabled; }
            set { this.Bybody.Enabled = value; }
        }

        public bool ByImageEnable
        {
            get { return this.Byimage.Enabled; }
            set { this.Byimage.Enabled = value; }
        }

        public bool hasEditByTargeting
        {
            set
            {
                if (value)
                {
                    this.Bytargeting.Text = "Dedine Targetings*";
                    this.Bytargeting.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold);
                }
                else
                {
                    this.Bytargeting.Text = "Dedline Targetings";
                    this.Bytargeting.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Regular);
                }
            }
        }
        public bool hasEditByTitle
        {
            set
            {
                if (value)
                {
                    this.Bytitle.Text = "Input Titles*";
                    this.Bytitle.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold);
                }
                else
                {
                    this.Bytitle.Text = "Input Titles";
                    this.Bytitle.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Regular);
                }
            }
        }
        public bool hasEditByBody
        {
            set
            {
                if (value)
                {
                    this.Bybody.Text = "Input Bodies*";
                    this.Bybody.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold);
                }
                else
                {
                    this.Bybody.Text = "Input Bodies";
                    this.Bybody.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Regular);
                }
            }
        }
        public bool hasEditByImage
        {
            set
            {
                if (value)
                {
                    this.Byimage.Text = "Select Images*";
                    this.Byimage.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold);
                }
                else
                {
                    this.Byimage.Text = "Select Images";
                    this.Byimage.Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Regular);
                }
            }
        }

        List<Button> btnList = new List<Button>();       
    }
}
